package cn.com.connext.scrm.repository.master;


import cn.com.connext.scrm.domain.master.AwardRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by wangzhan
 */
@Repository
public interface AwardRecordRepository extends JpaRepository<AwardRecord, String>, JpaSpecificationExecutor {

    List<AwardRecord> getByUnionIdAndActivityIdAndStateFalseOrderByCreateTime(String unionId, String activityId);

    @Query("select a from AwardRecord a where a.unionId = ?1 and a.cardId = ?2 and a.state = false ")
    List<AwardRecord> findByUnionIdAndCardId(String unionId, String cardId);

    AwardRecord getFirstByActivityIdAndUnionIdAndStateFalseOrderByCreateTime(String activityId, String unionId);

    List<AwardRecord> findByActivityId(String id);
}
